package com.jxnu.escms.Service.HealthService.impl;

import com.jxnu.escms.Dao.HealthDao.HealthDao;
import com.jxnu.escms.Service.HealthService.HealthPunch;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

@Service
public class HealthService implements HealthPunch {

    @Resource
    private HealthDao healthDao;

    @Override
    public int addPunch(int userId, Map<String, String> data) {
        // 添加打卡时间
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        String nowData = df.format(new Date());
        data.put("time", nowData);

        return healthDao.insertHealth(userId, data);
    }

    @Override
    public int updateUserHealth(String healthCode, int userId) {
        return healthDao.updateHealth(healthCode, userId);
    }
}
